/*
 * @Author: zhaopeng
 * @Date:   2015-10-30 14:29:22
 * @Last Modified by:   zhaopeng
 * @Last Modified time: 2015-10-30 14:49:02
 */
define(function() {
    function Cookies() {
        var self = this;
        self.set = function(name, value, hours) {
            var life = new Date().getTime();
            life += hours * 1000 * 60;
            var cookieStr = name + "=" + escape(value) + ";expires=" + new Date(life).toGMTString();
            document.cookie = cookieStr;
        };
        //获取cookie值
        self.get = function(name) {
            var cookies = document.cookie.split(";");
            if (cookies.length > 0) {
                var cookie = cookies[0].split("=");
                if (cookie[0] == name)
                    return unescape(cookie[1]);
            }
            return null;
        }
        self.remove = function(name) {
            var cookieStr = name + "=" + escape('null') + ";expires=" + new Date().toGMTString();
            document.cookie = cookieStr;
        };
    }
    return new Cookies();
});
